package com.jiangxjsy.admin.client;

import com.jiangxjsy.core.wrap.Result;
import com.jiangxjsy.core.wrap.ResultBuilder;
import com.jiangxjsy.model.hrm.entity.HrmEmployee;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * wukong-crm-master
 * 蒋胜宇
 * 2025/6/8 15:58
 */

@FeignClient(name = "hrm", fallback = HrmClient.HrmClientFallback.class)
public interface HrmClient {
    /**
     * 通过员工 ids 查询员工信息
     *
     * @param employeeIds 员工 ids
     * @return 员工信息
     */
    @PostMapping("/hrm/queryEmployeeListByIds")
    Result<Set<HrmEmployee>> queryEmployeeListByIds(@RequestBody List<Integer> employeeIds);

    /**
     * 员工异动
     */
    @PostMapping("/hrmJob/employeeChangeRecords")
    void employeeChangeRecords();

    /**
     * 查询登陆用户是否在人资员工中
     *
     * @return true 在人资员工中，false 不在人资员工中
     */
    @PostMapping("/hrmEmployee/queryIsInHrm")
    Result<Boolean> queryIsInHrm();


    @Component
    class HrmClientFallback implements HrmClient {
        /**
         * 查询员工信息
         *
         * @param employeeIds 员工 id
         * @return 员工信息
         */
        @Override
        public Result<Set<HrmEmployee>> queryEmployeeListByIds(List<Integer> employeeIds) {
            return ResultBuilder.ok(new HashSet<>());
        }

        /**
         * 员工异动
         */
        @Override
        public void employeeChangeRecords() {

        }

        /**
         * 查询登陆用户是否在人资员工中
         *
         * @return true 在人资员工中，false 不在人资员工中
         */
        @Override
        public Result<Boolean> queryIsInHrm() {
            return ResultBuilder.ok(false);
        }
    }
}
